<?php
/**
 * Created by PhpStorm.
 * User: renshan
 * Date: 16-6-18
 * Time: 下午9:56
 */

namespace ApiBundle\Exception;

use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use ApiBundle\Response\SecurityResponse;

/**
 * Class ApiTokenNotFoundException
 * @package ApiBundle\Exception
 * 自定义异常，当需要验证api_token并且api_token错误或者不存在时抛出
 */
class UserTokenNotFoundException  extends \RuntimeException implements HttpExceptionInterface
{
    
    private $statusCode;
    private $headers;

    //  api_token不存在或错误
    const   STATUS  = SecurityResponse::API_TOKEN_NOT_FOUND;
    const   MESSAGE = SecurityResponse::API_TOKEN_NOT_FOUND_MESSAGE;

    public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = array(), $code = 0)
    {
        $this->statusCode = $statusCode;
        $this->headers = $headers;

        parent::__construct($message, $code, $previous);
    }

    public function getStatusCode()
    {
        return $this->statusCode;
    }

    public function getHeaders()
    {
        return $this->headers;
    }

    /**
     * Set response headers.
     *
     * @param array $headers Response headers.
     */
    public function setHeaders(array $headers)
    {
        $this->headers = $headers;
    }
}